



<h2>DomMonitor</h2>
DomMonitor is useful tool to see performance of your site. It shows you:
<ul>
	<li> Overall execution time</li>
	<li> Overall SQL execution time</li>
	<li> Execution time of each query </li>
	<li> Overall require time of classes </li>
	<li> Require time of each classfile</li>
	<li> Helps finding bottlenecks and slow code.</li>
	<li> Allows online debugging</li>
</ul>
Preview of DomMonitor overall panel:<br>
<img src="{$mediaUrl}DomMonitor/overall.png" />






<h2>Activating DomMonitor</h2>
To activate DomMonitor simply time this in the end of your site url: <b>&debugMode=DOM_DEBUG_PASSWORD</b><<br>
see constant DOM_DEBUG_PASSWORD value from conf/runtime.conf.php file.<br>
<br>
Sample:<br> http://mySite.com/&debugMode=debugger
<br><br>
To turn it back off: &debugMode=off<br>
<br>
<b style="color:red">NOTICE!</b> Activated DomMonitor may ruin ajax requests. 
It outputs HTML to all pages, so your ajax request (For example XML or JSON) might get syntax errors.





<h2>Activating DomMonitor logging</h2>
DomMonitor logging is useful to analyze traffic on your site. 
It logs ip, sessionId, execution time, overall sql time, overall require time, overall user script time and all sql queries.
<br><br>
<b style="color:red">NOTICE!</b> Using logging causes overhead. It needs to make two insert queries each time page is requested!
<br><br>
it creates two tables into database: <b>dom_monitor_overall_log</b> and <b>dom_monitor_sql_log.</b><br>




<h2>Online debugging</h2>
Use trace function to send output to domMonitor panel.
<img src="{$mediaUrl}DomMonitor/1.png" />

{literal}
<pre class="code">
&lt;?php
// somewhere in your code
trace('I\'m online debugging message');
?&gt;
</pre>
{/literal}


<h2>Using gaps</h2>
Gaps are very handy tool to measure time of some code.

Sample code:
{literal}
<pre class="code">
&lt;?php
// register start
DomMonitor::gap('Starting','MyGap');

// spend some time
for( $i=0; $i<50000; $i++ );

// register end
DomMonitor::gap('Middle','MyGap'); 

// spend some more time
for( $i=0; $i<150000; $i++ );

// register end
DomMonitor::gap('Ending','MyGap');

?&gt;
</pre>
{/literal}
Result:<br>
<img src="{$mediaUrl}DomMonitor/gaps.png" />
As you can see from the image:<br>
1) From code start to "Starting" it took 0.0318 seconds. Notice that you also see what classes where loaded and sql queries made during that time.
2) From "Starting" to "Middle" it took 0.00472 seconds<br>
3) From "Middle" to "Ending" it took 0.0152 seconds.<br>